package com.zy.mydemo.view.controller;

import com.zy.mydemo.common.entity.UserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author:zhongyong
 * @Description：
 * @Date：Create in 2020/04/28
 */
@Controller
public class IndexController extends AbstractController {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @RequestMapping("/")
    public String index(Model model) {
        model.addAttribute("user", getUser());
        return "index/index";
    }

    @RequestMapping("/test")
    @ResponseBody
    public String test() {
        ValueOperations<String, String> valueOps = stringRedisTemplate.opsForValue();
        valueOps.set("zy_test", "yihu.com");
        System.out.println(valueOps.get("zy_test"));
        return null;
    }
}
